import { getAreaObj, regularRule, uploadType } from '@/utils/util'
import {
	searchConfig,
	BaseFormConfig as ConfigBaseConfig,
	ExtendFormConfig,
	ExtendDetailConfig,
} from '@/views/datacenter/basicData/homePractitioner/config'
export { searchConfig, ExtendFormConfig, ExtendDetailConfig }

export const BaseFormConfig = {
	inline: false,
	showBtn: false,
	labelPosition: 'top',
	column: ConfigBaseConfig.column
		.map((item) => {
			if (!['workType'].includes(item.prop)) {
				return item
			}
		})
		.filter(Boolean),
}
export const detailConfig = {
	inline: false,
	showBtn: false,
	labelPosition: 'left',
	column: [...BaseFormConfig.column],
	customeHeader: {
		type: 'CardTwo',
		title: 'practitionersName',
		avatar: 'staffPhoto',
		tipList: [{ prop: 'phone', type: 'tip-success', label: '联系电话' }],
		tagList: [
			{ prop: 'workTypeLabel', code: 'WORK_TYPE', custome: 'tag', type: 'success', label: '工作类型' },
			{ prop: 'serviceStateLabel', code: 'SERVICE_STATE', custome: 'tag', type: 'success', label: '服务状态' },
			{ prop: 'unitName', type: 'success', label: '所在单位' },
		],
		menuBtn: [],
	},
}

const tableConfig = {
	stripe: true,
	border: true,
	maxHeight: '80vh',
	columns: [
		{ label: '所属区', prop: 'unitAreaName' },
		{ label: '人员信息', prop: 'userInfo', width: 220, showOverflowTooltip: false, custome: 'UserCard', align: 'left' },
		{ label: '单位名称', prop: 'unitName' },
		{
			label: '文化程度',
			prop: 'cultureDegreeLabel',
		},
		{
			label: '专兼职',
			prop: 'workTypeLabel',
		},

		{
			label: '职业类型',
			prop: 'occupationTypeLabel',
		},
		{ prop: 'serviceStateLabel', code: 'SERVICE_STATE', custome: 'tag', label: '在职状态' },
		{
			label: '操作',
			prop: 'menu',
			width: 200,
			fixed: 'right',
		},
	],
}

export const api = {
	index: 'view_omBusinessPractitioners_page',
	add: 'view_dpFoundationPractitioners_gather',
	edit: 'view_omBusinessPractitioners_edit',
	detail: 'view_dpFoundationPractitioners_view',
	delete: 'view_omBusinessPractitioners_del',
	export: 'view_dpFoundationPractitioners_exportAll',
	rowKey: 'businessId',
}
export const baseConfig = {
	pageName: '养老从业人员',
	rowKey: 'id',
	businessRowKey: 'businessId',
	addLabel: '采集录入',
	tipLabel: 'practitionersName',
	dictcodes: [
		'LEAVEMANAGEMENT_LEAVE_TYPE',
		'BLOCK_CHAIN_STATUS',
		'JOB_TYPE',
		'punishmentLevel',
		'TRAINING_TYPE',
		'OCCUPATION_TYPE',
		'POSITION_TYPE',
		'REWARD_STATE',
		'HIRE_MODE',
		'WORK_TYPE',
		'HEALTHY_STATE',
		'NATURE',
		'SERVICE_STATE',
		'COMMON_FLAG',
		'ID_CARD_TYPE',
		'NATIONALITY',
		'POLITICAL_STATUS',
		'EDUCATION_DEGREE',
		'MARITAL_STATUS',
		'MARITAL_STATUS',
		'OCCUPATION_TYPE',
		'CERTIFICATE_CATEGORY',
		'PROOF_TYPE',
		'STAFF_MATERIAL_TYPE',
	],
	// exportMqTopic: '/ning/export/',
	exportMqTopic: [
		{
			topic: '/ning/export/dpFoundationPractitioners/',
			label: '基础数据',
			code: 2007,
			po: 'dpFoundationPractitionersPO',
		},
		{
			topic: '/ning/export/dpFoundationPractitionersExtend/',
			label: '扩展信息',
			code: 2008,
			po: 'dpFoundationPractitionersExtendPO',
		},
		{
			topic: '/ning/export/dpPractitionersExperience/',
			label: '从业经历',
			code: 2009,
			po: 'dpPractitionersExperiencePO',
		},
		{
			topic: '/ning/export/dpRewardPunishmentInfo/',
			label: '奖/处罚信息',
			code: 2012,
			po: 'dpRewardPunishmentInfoPO',
		},
		{
			topic: '/ning/export/dpSubsidyInfo/',
			label: '享受补贴信息',
			code: 2011,
			po: 'dpSubsidyInfoPO',
		},
		{
			topic: '/ning/export/dpTrainingRecord/',
			label: '培训记录',
			code: 2010,
			po: 'dpTrainingRecordPO',
		},
	],
	api,
	auth: {
		...api,
		mulitSet: 'mulitSet',
	},
	menuBtn: [
		{
			icon: 'editor',
			label: '查看档案',
			type: 'primary',
			operate: 'Archives',
			auth: api.detail,
			text: true,
			show: true,
		},
		{
			icon: 'delete',
			label: '删除',
			type: 'danger',
			operate: 'delete',
			auth: api.delete,
			text: true,
			show: true,
		},
	],
	dialogConfig: {
		width: '65%',
	},
	detailConfig,
	searchConfig,
	tableConfig,
	paramsObj: {
		code: 2033,
	},
	beforeOnLoadFormate: async (params) => {
		const unitAreaIds: any = getAreaObj(params.unitAreas, 'unit')
		const unitAreaNames: any = getAreaObj(params.unitAddress, 'unit')
		return Promise.resolve({
			...params,
			...unitAreaIds,
			...unitAreaNames,
			unitAreas: undefined,
			unitAreasName: undefined,
		})
	},
	onLoadFormate: async (arr) => {
		const tableData = arr.map((item) => {
			const unitAddress: any = getAreaObj(item, 'unit', 'set')
			return {
				...item,
				unitAddress: unitAddress.names,
				tableAreaName: [item.unitAreaName, item.unitStreetName, item.unitCommunityName].filter(Boolean).join(''),
			}
		})
		return Promise.resolve(Object.freeze(tableData))
	},
}
